# -*- coding:utf-8 -*-
"""
Created on Apr 14, 2011

@author: Lithuanian
"""
from algorithm import Heuristic
from manhattanHeuristic import manhattenSumHuristics
from pile2robotHeuristic import pile2robot
from numOfPilesPenalty import numOfPilesPenalty
from avoidPocketsHeuristic import avoidPockets

class mixed(Heuristic):
    def evaluate(self, problem_state):
        ratio = pile2robot()
        numOfPiles = numOfPilesPenalty()
        return numOfPiles.evaluate(problem_state) \
                + ratio.evaluate(problem_state)

class avoid(Heuristic):
    def evaluate(self, problem_state):
        numOfPiles = numOfPilesPenalty()
        avoid = avoidPockets()
        man = manhattenSumHuristics()
        return numOfPiles.evaluate(problem_state) \
                + man.evaluate(problem_state) \
                + avoid.evaluate(problem_state)
                
class mixedWithManSum(Heuristic):
    def __init__(self, d = None, pilesPenalty = None, isMul = None):
        if d is None:
            d = 0.9
        self.delta = d
        
        if pilesPenalty is None:
            self.pilesPenalty = 3
        else:
            self.pilesPenalty = pilesPenalty
        if isMul is None:
            self.isMul = False
        else:
            self.isMul = True
        
    def evaluate(self, problem_state):
        man = manhattenSumHuristics()
        ratio = pile2robot()
        numOfPiles = numOfPilesPenalty(self.pilesPenalty, self.isMul)
        return numOfPiles.evaluate(problem_state) \
                + (1-self.delta)*ratio.evaluate(problem_state) \
                + self.delta*man.evaluate(problem_state)
                